package src.percolation;

import java.util.Map;
import java.util.Random;
import java.util.TreeMap;

import src.utils.Utils;

public class Pr2 {

	public static void main(String[] argvs) throws Exception {
		
		int large;

		double minProba;
		double maxProba;
		double increment;
		
		try {
			large = new Integer(argvs[0]);
			minProba = new Double(argvs[1]);
			maxProba = new Double(argvs[2]);
			increment = new Double(argvs[3]);
			
		} catch (Exception e) {
			showUsage();
			return;
		}
		
		Random gen = new Random();

		double probability;
		
		Map<Double,Double> criticalResults = new TreeMap<Double, Double>();
		
		for(probability = minProba; probability<maxProba; probability += increment) {
			
			
			long seed = gen.nextLong();
			Red red = new Red(large,seed);
			
			red.createGrid(probability);
			criticalResults.put(probability,red.percolationIntensity());					
		}
		
		Utils.printToFile(criticalResults,"INT"+large+".dat");
	}
	
	private static void showUsage() {
		System.out.println("Usage: ");
		
		System.out.println("<netSize> <minProba> <maxProba> <increment>\n");
		
		System.out.println("<netSize>: size of net.");
		System.out.println("<minProba>: minimum probability.");
		System.out.println("<maxProba>: maximum probability.");
		System.out.println("<increment>: increment between probabilities.");
		
	}
}
